<%-- 
    Document   : request_bloqueo_cuentas
    Created on : 11/10/2011, 09:06:52 PM
    Author     : Jose
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%@ page import="PaquetesJL.*" %>
<%@page import="java.sql.ResultSet" %>

<%
    HttpSession objSesion = request.getSession(false); 
    String usuario = (String)objSesion.getAttribute("username");

    String descripcion=request.getParameter("descripcion");
    String id_cuenta=request.getParameter("id_cuenta");
    String id_usuario="";
    
    String sqlServer = pageContext.getServletContext().getInitParameter("sqlServer");
    String databaseName = pageContext.getServletContext().getInitParameter("databaseName");
    String userName = pageContext.getServletContext().getInitParameter("userName");
    String PasswordP = pageContext.getServletContext().getInitParameter("password");
    String Backup = pageContext.getServletContext().getInitParameter("RutaBackup");

    byte[] decodedBytes = ConexionBD.decode(PasswordP);
    String decodedPassword = new String(decodedBytes).trim();

    ConexionBD Conexion = new ConexionBD(sqlServer, databaseName, userName, decodedPassword, Backup);
    Conexion.IniciarConexion();
    ResultSet r=Conexion.EjecutarConsulta(
            "BEGIN TRANSACTION;"
            + "SELECT id_usuario "
            + "FROM USUARIO "
            + "WHERE nombre='"+usuario+"'; "
            + "COMMIT;");
    if(r.next()){
        id_usuario=r.getString(1);
    }
    Conexion.CerrarConexion();       
    
    Conexion = new ConexionBD(sqlServer, databaseName, userName, decodedPassword, Backup);
    Conexion.IniciarConexion();
    r=Conexion.EjecutarConsulta("EXEC dbo.CancelarCuenta '"+descripcion+"',"+id_cuenta+","+id_usuario+";");
    if(r.next()){
        out.print(r.getString(1));
    }
    Conexion.CerrarConexion();
%>